Converting characters to dates

#read data file
MDClimate <- read.csv("ClimateData_wDates.csv")
head(MDClimate)
dates <- MDClimate$Date
head(dates)
str(dates)
#convert dates from character class to dates class
ConvertedDate <- as.Date(dates)
#check to see if it worked
class(ConvertedDate)

Monthly Precipitation 1953-2021

str(MDClimate)
## 'data.frame':    819 obs. of  6 variables:
##  $ Date: chr  "1953-01-01" "1953-02-01" "1953-03-01" "1953-04-01" ...
##  $ PRCP: num  12.23 5.43 4.5 1.97 3.3 ...
##  $ SNOW: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ TAVG: num  46.3 43.2 44.4 49.1 53 56.5 64.5 64.9 63.2 53 ...
##  $ TMAX: num  51.5 51.4 53.3 58.8 62.3 66.2 79.7 77.5 76.6 64.8 ...
##  $ TMIN: num  41 35.1 35.6 39.4 43.6 46.9 49.3 52.3 49.8 41.2 ...
PRCP <- MDClimate$PRCP

p <- MDClimate %>%
ggplot( aes(x=ConvertedDate, y=PRCP)) +
    geom_area(fill="#69b3a2", alpha=0.5) +
    geom_line(color="#69b3a2") +
    ylab("precipitation (in)") +
  xlab("January 1953 - July 2021") +
    theme_ipsum()

p <- ggplotly(p)
## Warning: Removed 3 rows containing missing values (position_stack).
p

Monthly Average Temperature

str(MDClimate)
## 'data.frame':    819 obs. of  6 variables:
##  $ Date: chr  "1953-01-01" "1953-02-01" "1953-03-01" "1953-04-01" ...
##  $ PRCP: num  12.23 5.43 4.5 1.97 3.3 ...
##  $ SNOW: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ TAVG: num  46.3 43.2 44.4 49.1 53 56.5 64.5 64.9 63.2 53 ...
##  $ TMAX: num  51.5 51.4 53.3 58.8 62.3 66.2 79.7 77.5 76.6 64.8 ...
##  $ TMIN: num  41 35.1 35.6 39.4 43.6 46.9 49.3 52.3 49.8 41.2 ...
TAVG <- MDClimate$TAVG

q <- MDClimate %>%
ggplot( aes(x=ConvertedDate, y=TAVG)) +
    geom_line(color="indianred4") +
    ylab("Average Temperature (F)") +
  xlab("January 1953 - July 2021") +
    theme_ipsum()

q <- ggplotly(q)
q

Monthly Minimum Temperature

str(MDClimate)
## 'data.frame':    819 obs. of  6 variables:
##  $ Date: chr  "1953-01-01" "1953-02-01" "1953-03-01" "1953-04-01" ...
##  $ PRCP: num  12.23 5.43 4.5 1.97 3.3 ...
##  $ SNOW: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ TAVG: num  46.3 43.2 44.4 49.1 53 56.5 64.5 64.9 63.2 53 ...
##  $ TMAX: num  51.5 51.4 53.3 58.8 62.3 66.2 79.7 77.5 76.6 64.8 ...
##  $ TMIN: num  41 35.1 35.6 39.4 43.6 46.9 49.3 52.3 49.8 41.2 ...
TMIN <- MDClimate$TMIN

q <- MDClimate %>%
ggplot( aes(x=ConvertedDate, y=TMIN)) +
    geom_line(color="midnightblue") +
    ylab("Minimum Temperature (F)") +
  xlab("January 1953 - July 2021") +
    theme_ipsum()

q <- ggplotly(q)
q

Monthly Maximum Temperatute

TMAX <- MDClimate$TMAX

x <- MDClimate %>%
ggplot( aes(x=ConvertedDate, y=TMAX)) +
    geom_line(color="sienna1") +
    ylab("Maximum Temperature (F)") +
  xlab("January 1953 - July 2021") +
    theme_ipsum()

x <- ggplotly(x)
x